import Fade from './Fade';
import Slide from './Slide';
import { setEl, setType } from './utils';

// options类型
interface IOptions {
  el: string;
  type: TYPE | string;
}

export enum TYPE {
  FADE = 'fade',
  SLIDE = 'slide'
}

class Tab {
  //私有属性,仅自身用
  private _el: HTMLElement;
  private _type: TYPE | string;

  constructor(options: IOptions) {
    const { el, type }: IOptions = options;

    this._type = setType(type);
    //包装el
    this._el = setEl(el, this._type as TYPE);
  }

  create() {
    // console.log(this._el, this._type);
    //<div class="tab fade"></div> 'fade'

    switch (this._type) {
      case TYPE.FADE:
        return new Fade(this._el);
      case TYPE.SLIDE:
        return new Slide(this._el);
      default:
        break;
    }
  }
}

export default Tab;
